const TOKEN_NAME = 'session_id';

// 获取 token
const getToken = (NAME = TOKEN_NAME) => {
  const str = localStorage.getItem(NAME);
  return JSON.parse(str);
};

// 设置 token
const setToken = (VALUE, NAME = TOKEN_NAME) => {
  const str = JSON.stringify(VALUE);
  localStorage.setItem(NAME, str);
};

// 删除 token
const removeToken = (NAME = TOKEN_NAME) => localStorage.removeItem(NAME);

// 是否登录（有权限）
const isAuth = () => !!getToken();

export { getToken, setToken, removeToken, isAuth };
